package com.joysuch.wwyt.bp.service.impl;

import com.joysuch.wwyt.bp.service.BpRedisService;
import com.joysuch.wwyt.config.RedisClient;
import com.joysuch.wwyt.core.common.ajax.ResultBean;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.util.Assert;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

/**
 * @Author ZhangDong
 * @Date 2020/12/29 10:15
 */
@Service
@Slf4j
@Transactional(rollbackFor = Exception.class)
public class BpRedisServiceImpl implements BpRedisService {

    @Resource
    private RedisClient redisClient;

    @Override
    public ResultBean removeStringKey(String key) {
        Assert.notNull(key, "key cannot be null");
        redisClient.removeKey(key);
        return ResultBean.defaultSuccessResult();
    }

    @Override
    public ResultBean removeMapKey(String key) {
        Assert.notNull(key, "key cannot be null");
        redisClient.delMap(key);
        return ResultBean.defaultSuccessResult();
    }

}
